define yumlocal::group (
  $ensure = present
) {
  Exec {
    path        => '/bin:/usr/bin:/sbin:/usr/sbin',
    environment => 'LC_ALL=C'
  }

  case $ensure {
    present,installed: {
      exec { "yum-groupinstall-${name}":
        command => "yum -y groupinstall '${name}'",
        unless  => "yum grouplist '${name}' | egrep '^Installed.+Groups:$'",
        timeout => 0,
      }
    }

    absent,purged: {
      exec { "yum-groupremove-${name}":
        command => "yum -y groupremove '${name}'",
        onlyif  => "yum grouplist '${name}' | egrep '^Installed.+Groups:$'",
        timeout => 0,
      }
    }

    default: {
      fail("Invalid ensure state: ${ensure}")
    }
  }
}
